<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<style>
.goods_image{
}
.goods_image ul{
	width:100%;
	list-style:none;
	line-height:20px;
}
.goods_image ul li{width:200px;padding:10px;float:left;margin:15px;font-weight: bold;}
.goods_image .oper{
	padding: 10px 30px;
}
</style>
<div class="pageContent">
	<form method="post" action="${rootUrl}/goods/goods-image" class="pageForm required-validate" onsubmit="return validateCallback(this, newDialogAjaxDone);">
		<div class="pageFormContent" layoutH="56">
			<dl class="nowrap">
				<dt></dt>
				<dd class="goods_image" style="width: 100%">
				<ul>
				<c:forEach items="${goodsImages}" var="goodsImage" varStatus="status">
					<li>
						<input type="hidden" name="goodsImages[${status.index}].id" value="${goodsImage.id}">
						<input type="hidden" name="goodsImages[${status.index}].goods.id" value="${goodsImage.goods.id }">
						<input type="hidden" name="goodsImages[${status.index}].goodsSpecValue.id" value="${goodsImage.goodsSpecValue.id }">
						<input type="hidden" name="goodsImages[${status.index}].sort" value="${goodsImage.sort }">
						<input name="goodsImages[${status.index}].imgurl" id="goods_img_url_a${status.count}"  type="hidden" size="30" value="${goodsImage.imgurl }" />
						<div class="imgContainer"><a href="#" onclick="iFileUploader.upImg('goods_img_url_a${status.count}','goods_img_a${status.count}');">
						<img id="goods_img_a${status.count}" src="<c:if test="${goodsImage.imgurl != ''}">${goodsImage.imgurl }</c:if>" /></a></div>
						<div class="oper">
							<a title="确定要删除这个记录吗?" target="dialogAjaxTodo" style="float: left" href="${rootUrl}/goods/goods-image/${goodsSpec.id}?_method=delete">删除</a>
							<span style="float: right;">设为默认
								<input type="checkbox" value="1" class="_chk_default" name="goodsImages[${status.index}].isDefault" <c:if test="${goodsImage.isDefault == 1}">checked="checked"</c:if>>
							</span>
						</div>				
					</li>
				</c:forEach>
				</ul>
				</dd>
			</dl>
		</div>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>
<script type="text/javascript">
   	var pHeight = $("#goods_detail").parent().css("height");
   	var editor = new UE.ui.Editor({initialFrameHeight:450,initialFrameWidth:'100%'});
   	editor.render("goods_detail");
   	/**var zindex = $.pdialog._current.css("z-index");
   	editor.addListener('beforefullscreenchange',function(event,isFullScreen){
	  if(!isFullScreen){
	   $.pdialog._current.css("z-index",zindex);
	  }
   	});**/
   	<c:forEach items="${goodsImages}" var="goodsImage" varStatus="status">
   		iFileUploader.initImg("_goods_img","goods_img_url_a${status.count}","goods_img_a${status.count}",true);
	</c:forEach>
	
	$(function(){
		var allBox = $(":checkbox");
		var pre;
	    allBox.click(function () {
	        allBox.removeAttr("checked");
	    	if($(this).parent().parent().parent().find("img").attr("src") == ""){
	    		if(pre){
	    			$(pre).attr("checked", "checked");
	    		}
	    	}else {
	        	$(this).attr("checked", "checked");
	        	pre = $(this);
	        }
	    });
	})
	function setDefault(){
		
	}
</script>